//FileName   : pmem
//Author     : -
//Description: pmem
//ModifyDate : 2019-5-8
//Company    : -
//Copy right : -


module pmem (
    input               clk,
    input               rst_n,
    output     [7:0]    pmem_rdat,
    input     [9:0]     pmem_adr,
    output reg          pmem_ack,
    input               pmem_cs
);
parameter ROM_INFILE                = "./rom.hex";
`define ROM_FILE ROM_INFILE

//internal wire define

//internal temp define
reg [9:0]     pmem_adr_d1;

//memory define
reg [7:0]     rom[0:1023];
initial begin
$readmemh(`ROM_FILE,rom);
end



//---------------------------------------------
//Function: AA
//---------------------------------------------

always @(posedge clk)
begin
    if(!rst_n)
        pmem_adr_d1 <= 10'd0;
    else begin
        pmem_adr_d1 <= pmem_adr;
    end
end

assign pmem_rdat = rom[pmem_adr_d1];

always @(posedge clk)
begin
    if(!rst_n)
        pmem_ack <= 1'd0;
    else begin
        pmem_ack <= pmem_cs;
    end
end

endmodule
